package com.ly.mp.cmc.common.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: ly-songpengfei
 * @Date: 2025/8/5 23:20
 * @Description: 过滤器配置类
 * @Version: 1.0
 */
@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<WebFilter> registerWebFilter() {
        FilterRegistrationBean<WebFilter> bean = new FilterRegistrationBean<>();
        bean.setFilter(new WebFilter());
        bean.addUrlPatterns("/*"); // 指定拦截路径
        bean.setOrder(1);              // 设置执行顺序（数字越小优先级越高）
        bean.setName("webFilter");      // 可选：过滤器名称
        return bean;
    }

}
